package com.ds;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Main {

	public static void main(String[] args) {
		System.out.println("Program is starting...");
		PreparedStatement 	pstmt 	= null;
		ResultSet 			rs 		= null;
		Connection 			conn 	= null;
		int count = 0;
		try {
			// Step 1. Initial application context
			//    call when start web-service
			System.out.println(" spring context is loading...");
			AppContext.initContext();
			System.out.println(" spring context is loaded!");

			// Step 2. Get connection
			conn = AppContext.getConnection();
			
			// 3. TEST Connection
			for (int i = 0; i < 10000; i++) {
				count ++;
				pstmt = conn.prepareStatement("SELECT logonid from BGUSER ");
				rs = pstmt.executeQuery();
				while (rs.next()) {
					System.out.println("USER:  " + rs.getString(1));
				}
				pstmt.close();
			}

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				pstmt.close();
			} catch (Exception e) {
			}
		}
		System.out.println("Done! " + count);
	}

}
